bakeshop/dark
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
bakeshop/dark
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
bakeshop/dark
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
bakeshop/dark
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
bakeshop/dark
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
bakeshop/dark
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
bakeshop/dark
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
bakeshop/dark
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
bakeshop/dark
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
bakeshop/dark
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
bakeshop/dark
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
bakeshop/dark
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
bakeshop/dark
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
bakeshop/dark
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
bakeshop/dark
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
bakeshop/light
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
bakeshop/light
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
bakeshop/light
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
bakeshop/light
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
bakeshop/light
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
bakeshop/light
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
bakeshop/light
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
bakeshop/light
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
bakeshop/light
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
bakeshop/light
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
bakeshop/light
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
bakeshop/light
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
bakeshop/light
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
bakeshop/light
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
bakeshop/light
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
capote/dark
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
capote/dark
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
capote/dark
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
capote/dark
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
capote/dark
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
capote/dark
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
capote/dark
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
capote/dark
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
capote/dark
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
capote/dark
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
capote/dark
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
capote/dark
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
capote/dark
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
capote/dark
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
capote/dark
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
capote/light
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
capote/light
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
capote/light
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
capote/light
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
capote/light
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
capote/light
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
capote/light
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
capote/light
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
capote/light
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
capote/light
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
capote/light
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
capote/light
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
capote/light
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
capote/light
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
capote/light
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
cascadite/dark
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
cascadite/dark
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
cascadite/dark
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
cascadite/dark
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
cascadite/dark
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
cascadite/dark
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
cascadite/dark
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
cascadite/dark
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
cascadite/dark
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
cascadite/dark
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
cascadite/dark
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
cascadite/dark
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
cascadite/dark
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
cascadite/dark
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
cascadite/dark
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
cascadite/light
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
cascadite/light
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
cascadite/light
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
cascadite/light
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
cascadite/light
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
cascadite/light
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
cascadite/light
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
cascadite/light
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
cascadite/light
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
cascadite/light
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
cascadite/light
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
cascadite/light
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
cascadite/light
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
cascadite/light
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
cascadite/light
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
darting/dark
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
darting/dark
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
darting/dark
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
darting/dark
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
darting/dark
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
darting/dark
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
darting/dark
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
darting/dark
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
darting/dark
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
darting/dark
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
darting/dark
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
darting/dark
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
darting/dark
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
darting/dark
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
darting/dark
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
darting/light
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
darting/light
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
darting/light
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
darting/light
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
darting/light
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
darting/light
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
darting/light
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
darting/light
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
darting/light
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
darting/light
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
darting/light
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
darting/light
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
darting/light
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
darting/light
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
darting/light
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
decarch/dark
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
decarch/dark
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
decarch/dark
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
decarch/dark
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
decarch/dark
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
decarch/dark
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
decarch/dark
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
decarch/dark
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
decarch/dark
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
decarch/dark
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
decarch/dark
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
decarch/dark
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
decarch/dark
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
decarch/dark
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
decarch/dark
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
decarch/light
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
decarch/light
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
decarch/light
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
decarch/light
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
decarch/light
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
decarch/light
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
decarch/light
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
decarch/light
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
decarch/light
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
decarch/light
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
decarch/light
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
decarch/light
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
decarch/light
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
decarch/light
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
decarch/light
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
difformed/dark
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
difformed/dark
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
difformed/dark
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
difformed/dark
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
difformed/dark
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
difformed/dark
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
difformed/dark
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
difformed/dark
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
difformed/dark
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
difformed/dark
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
difformed/dark
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
difformed/dark
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
difformed/dark
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
difformed/dark
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
difformed/dark
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
difformed/light
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
difformed/light
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
difformed/light
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
difformed/light
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
difformed/light
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
difformed/light
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
difformed/light
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
difformed/light
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
difformed/light
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
difformed/light
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
difformed/light
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
difformed/light
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
difformed/light
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
difformed/light
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
difformed/light
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
fulfiller/dark
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
fulfiller/dark
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
fulfiller/dark
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
fulfiller/dark
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
fulfiller/dark
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
fulfiller/dark
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
fulfiller/dark
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
fulfiller/dark
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
fulfiller/dark
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
fulfiller/dark
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
fulfiller/dark
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
fulfiller/dark
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
fulfiller/dark
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
fulfiller/dark
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
fulfiller/dark
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
fulfiller/light
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
fulfiller/light
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
fulfiller/light
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
fulfiller/light
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
fulfiller/light
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
fulfiller/light
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
fulfiller/light
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
fulfiller/light
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
fulfiller/light
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
fulfiller/light
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
fulfiller/light
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
fulfiller/light
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
fulfiller/light
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
fulfiller/light
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
fulfiller/light
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
gutweed/dark
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
gutweed/dark
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
gutweed/dark
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
gutweed/dark
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
gutweed/dark
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
gutweed/dark
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
gutweed/dark
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
gutweed/dark
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
gutweed/dark
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
gutweed/dark
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
gutweed/dark
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
gutweed/dark
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
gutweed/dark
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
gutweed/dark
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
gutweed/dark
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
gutweed/light
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
gutweed/light
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
gutweed/light
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
gutweed/light
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
gutweed/light
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
gutweed/light
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
gutweed/light
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
gutweed/light
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
gutweed/light
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
gutweed/light
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
gutweed/light
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
gutweed/light
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
gutweed/light
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
gutweed/light
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
gutweed/light
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
homoplast/dark
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
homoplast/dark
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
homoplast/dark
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
homoplast/dark
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
homoplast/dark
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
homoplast/dark
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
homoplast/dark
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
homoplast/dark
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
homoplast/dark
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
homoplast/dark
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
homoplast/dark
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
homoplast/dark
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
homoplast/dark
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
homoplast/dark
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
homoplast/dark
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
homoplast/light
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
homoplast/light
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
homoplast/light
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
homoplast/light
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
homoplast/light
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
homoplast/light
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
homoplast/light
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
homoplast/light
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
homoplast/light
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
homoplast/light
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
homoplast/light
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
homoplast/light
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
homoplast/light
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
homoplast/light
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
homoplast/light
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
incandent/dark
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
incandent/dark
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
incandent/dark
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
incandent/dark
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
incandent/dark
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
incandent/dark
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
incandent/dark
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
incandent/dark
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
incandent/dark
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
incandent/dark
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
incandent/dark
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
incandent/dark
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
incandent/dark
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
incandent/dark
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
incandent/dark
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
incandent/light
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
incandent/light
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
incandent/light
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
incandent/light
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
incandent/light
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
incandent/light
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
incandent/light
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
incandent/light
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
incandent/light
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
incandent/light
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
incandent/light
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
incandent/light
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
incandent/light
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
incandent/light
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
incandent/light
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
mikie/dark
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
mikie/dark
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
mikie/dark
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
mikie/dark
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
mikie/dark
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
mikie/dark
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
mikie/dark
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
mikie/dark
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
mikie/dark
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
mikie/dark
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
mikie/dark
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
mikie/dark
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
mikie/dark
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
mikie/dark
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
mikie/dark
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
mikie/light
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
mikie/light
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
mikie/light
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
mikie/light
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
mikie/light
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
mikie/light
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
mikie/light
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
mikie/light
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
mikie/light
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
mikie/light
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
mikie/light
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
mikie/light
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
mikie/light
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
mikie/light
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
mikie/light
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
overroyal/dark
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
overroyal/dark
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
overroyal/dark
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
overroyal/dark
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
overroyal/dark
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
overroyal/dark
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
overroyal/dark
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
overroyal/dark
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
overroyal/dark
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
overroyal/dark
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
overroyal/dark
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
overroyal/dark
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
overroyal/dark
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
overroyal/dark
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
overroyal/dark
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
overroyal/light
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
overroyal/light
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
overroyal/light
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
overroyal/light
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
overroyal/light
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
overroyal/light
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
overroyal/light
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
overroyal/light
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
overroyal/light
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
overroyal/light
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
overroyal/light
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
overroyal/light
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
overroyal/light
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
overroyal/light
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
overroyal/light
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
peroral/dark
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
peroral/dark
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
peroral/dark
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
peroral/dark
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
peroral/dark
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
peroral/dark
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
peroral/dark
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
peroral/dark
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
peroral/dark
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
peroral/dark
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
peroral/dark
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
peroral/dark
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
peroral/dark
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
peroral/dark
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
peroral/dark
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
peroral/light
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
peroral/light
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
peroral/light
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
peroral/light
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
peroral/light
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
peroral/light
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
peroral/light
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
peroral/light
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
peroral/light
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
peroral/light
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
peroral/light
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
peroral/light
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
peroral/light
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
peroral/light
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
peroral/light
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
purreic/dark
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
purreic/dark
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
purreic/dark
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
purreic/dark
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
purreic/dark
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
purreic/dark
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
purreic/dark
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
purreic/dark
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
purreic/dark
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
purreic/dark
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
purreic/dark
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
purreic/dark
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
purreic/dark
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
purreic/dark
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
purreic/dark
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
purreic/light
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
purreic/light
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
purreic/light
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
purreic/light
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
purreic/light
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
purreic/light
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
purreic/light
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
purreic/light
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
purreic/light
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
purreic/light
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
purreic/light
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
purreic/light
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
purreic/light
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
purreic/light
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
purreic/light
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
realm/dark
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
realm/dark
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
realm/dark
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
realm/dark
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
realm/dark
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
realm/dark
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
realm/dark
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
realm/dark
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
realm/dark
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
realm/dark
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
realm/dark
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
realm/dark
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
realm/dark
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
realm/dark
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
realm/dark
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
realm/light
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
realm/light
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
realm/light
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
realm/light
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
realm/light
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
realm/light
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
realm/light
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
realm/light
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
realm/light
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
realm/light
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
realm/light
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
realm/light
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
realm/light
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
realm/light
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
realm/light
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
resection/dark
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
resection/dark
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
resection/dark
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
resection/dark
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
resection/dark
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
resection/dark
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
resection/dark
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
resection/dark
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
resection/dark
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
resection/dark
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
resection/dark
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
resection/dark
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
resection/dark
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
resection/dark
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
resection/dark
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
resection/light
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
resection/light
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
resection/light
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
resection/light
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
resection/light
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
resection/light
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
resection/light
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
resection/light
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
resection/light
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
resection/light
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
resection/light
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
resection/light
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
resection/light
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
resection/light
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
resection/light
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
ringbill/dark
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
ringbill/dark
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
ringbill/dark
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
ringbill/dark
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
ringbill/dark
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
ringbill/dark
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
ringbill/dark
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
ringbill/dark
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
ringbill/dark
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
ringbill/dark
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
ringbill/dark
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
ringbill/dark
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
ringbill/dark
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
ringbill/dark
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
ringbill/dark
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
ringbill/light
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
ringbill/light
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
ringbill/light
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
ringbill/light
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
ringbill/light
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
ringbill/light
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
ringbill/light
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
ringbill/light
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
ringbill/light
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
ringbill/light
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
ringbill/light
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
ringbill/light
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
ringbill/light
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
ringbill/light
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
ringbill/light
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
silvester/dark
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
silvester/dark
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
silvester/dark
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
silvester/dark
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
silvester/dark
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
silvester/dark
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
silvester/dark
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
silvester/dark
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
silvester/dark
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
silvester/dark
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
silvester/dark
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
silvester/dark
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
silvester/dark
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
silvester/dark
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
silvester/dark
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
silvester/light
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
silvester/light
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
silvester/light
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
silvester/light
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
silvester/light
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
silvester/light
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
silvester/light
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
silvester/light
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
silvester/light
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
silvester/light
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
silvester/light
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
silvester/light
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
silvester/light
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
silvester/light
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
silvester/light
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
soleplate/dark
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
soleplate/dark
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
soleplate/dark
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
soleplate/dark
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
soleplate/dark
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
soleplate/dark
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
soleplate/dark
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
soleplate/dark
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
soleplate/dark
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
soleplate/dark
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
soleplate/dark
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
soleplate/dark
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
soleplate/dark
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
soleplate/dark
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
soleplate/dark
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
soleplate/light
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
soleplate/light
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
soleplate/light
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
soleplate/light
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
soleplate/light
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
soleplate/light
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
soleplate/light
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
soleplate/light
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
soleplate/light
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
soleplate/light
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
soleplate/light
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
soleplate/light
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
soleplate/light
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
soleplate/light
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
soleplate/light
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
somatical/dark
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
somatical/dark
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
somatical/dark
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
somatical/dark
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
somatical/dark
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
somatical/dark
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
somatical/dark
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
somatical/dark
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
somatical/dark
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
somatical/dark
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
somatical/dark
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
somatical/dark
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
somatical/dark
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
somatical/dark
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
somatical/dark
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
somatical/light
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
somatical/light
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
somatical/light
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
somatical/light
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
somatical/light
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
somatical/light
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
somatical/light
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
somatical/light
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
somatical/light
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
somatical/light
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
somatical/light
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
somatical/light
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
somatical/light
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
somatical/light
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
somatical/light
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
sphecina/dark
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
sphecina/dark
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
sphecina/dark
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
sphecina/dark
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
sphecina/dark
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
sphecina/dark
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
sphecina/dark
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
sphecina/dark
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
sphecina/dark
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
sphecina/dark
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
sphecina/dark
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
sphecina/dark
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
sphecina/dark
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
sphecina/dark
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
sphecina/dark
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
sphecina/light
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
sphecina/light
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
sphecina/light
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
sphecina/light
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
sphecina/light
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
sphecina/light
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
sphecina/light
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
sphecina/light
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
sphecina/light
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
sphecina/light
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
sphecina/light
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
sphecina/light
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
sphecina/light
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
sphecina/light
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
sphecina/light
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
suberane/dark
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
suberane/dark
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
suberane/dark
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
suberane/dark
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
suberane/dark
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
suberane/dark
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
suberane/dark
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
suberane/dark
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
suberane/dark
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
suberane/dark
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
suberane/dark
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
suberane/dark
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
suberane/dark
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
suberane/dark
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
suberane/dark
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
suberane/light
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
suberane/light
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
suberane/light
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
suberane/light
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
suberane/light
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
suberane/light
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
suberane/light
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
suberane/light
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
suberane/light
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
suberane/light
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
suberane/light
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
suberane/light
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
suberane/light
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
suberane/light
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
suberane/light
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
togate/dark
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
togate/dark
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
togate/dark
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
togate/dark
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
togate/dark
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
togate/dark
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
togate/dark
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
togate/dark
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
togate/dark
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
togate/dark
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
togate/dark
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
togate/dark
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
togate/dark
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
togate/dark
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
togate/dark
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
togate/light
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
togate/light
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
togate/light
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
togate/light
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
togate/light
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
togate/light
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
togate/light
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
togate/light
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
togate/light
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
togate/light
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
togate/light
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
togate/light
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
togate/light
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
togate/light
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
togate/light
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
undermath/dark
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
undermath/dark
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
undermath/dark
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
undermath/dark
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
undermath/dark
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
undermath/dark
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
undermath/dark
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
undermath/dark
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
undermath/dark
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
undermath/dark
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
undermath/dark
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
undermath/dark
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
undermath/dark
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
undermath/dark
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
undermath/dark
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
undermath/light
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
undermath/light
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
undermath/light
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
undermath/light
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
undermath/light
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
undermath/light
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
undermath/light
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
undermath/light
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
undermath/light
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
undermath/light
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
undermath/light
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
undermath/light
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
undermath/light
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
undermath/light
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
undermath/light
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
ungaining/dark
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
ungaining/dark
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
ungaining/dark
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
ungaining/dark
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
ungaining/dark
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
ungaining/dark
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
ungaining/dark
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
ungaining/dark
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
ungaining/dark
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
ungaining/dark
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
ungaining/dark
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
ungaining/dark
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
ungaining/dark
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
ungaining/dark
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
ungaining/dark
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))
ungaining/light
https://github.com/multitheftauto/multitheftauto/tree/master/MTA10/gui/CGUITab_Impl.cpp
1 /*****************************************************************************
2 *
3 * PROJECT: Multi Theft Auto v1.0
4 * LICENSE: See LICENSE in the top level directory
5 * FILE: gui/CGUITab_Impl.cpp
6 * PURPOSE: Tab widget class
7 * DEVELOPERS: Christian Myhre Lundheim <>
8 * Cecill Etheredge <ijsf@gmx.net>
9 *
10 * Multi Theft Auto is available from http://www.multitheftauto.com/
11 *
12 *****************************************************************************/
13
14 #include "StdInc.h"
15
16 CGUITab_Impl::CGUITab_Impl ( CGUI_Impl* pGUI, CGUIElement_Impl* pParent,
const char* szCaption )
17 {
18 m_pManager = pGUI;
19
20 // Get an unique identifier for CEGUI
21 char szUnique [CGUI_CHAR_SIZE];
22 pGUI->GetUniqueName ( szUnique );
23
24 // Create the window and set default settings
25 m_pWindow = pGUI->GetWindowManager ()->createWindow (
"DefaultWindow", szUnique );
26 m_pWindow->setDestroyedByParent (
false );
27 m_pWindow->setText ( szCaption );
28
29 // Store the pointer to this CGUI element in the CEGUI element
30 m_pWindow->setUserData (
reinterpret_cast <
void* > (
this ) );
31
32 AddEvents ();
33
34 // If a parent is specified, add it to it's children list, if not, add it as a child to the pManager
35 if ( pParent )
36 {
37 SetParent ( pParent );
38
39 // Adjust the tab button (pParent should be a TabControl!)
40 reinterpret_cast < CEGUI::TabControl* > ( ((CGUITabPanel_Impl*)pParent)->m_pWindow ) -> setAbsoluteTabHeight (
24.0f );
41 }
42 else
43 {
44 pGUI->AddChild (
this );
45 SetParent (
NULL );
46 }
47 }
48
49
50 CGUITab_Impl::~CGUITab_Impl (
void )
51 {
52 DestroyElement ();
53 }
54
55
56 void CGUITab_Impl::SetCaption (
const char* szCaption )
57 {
58 CEGUI::String strCaption;
59
60 if ( szCaption ) strCaption.assign ( szCaption );
61 m_pWindow->setText ( strCaption );
62 }
ungaining/light
https://github.com/mirrors/linux-2.6/tree/master/arch/arm/plat-mxc/iram_alloc.c
1 /*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20 #include <linux/kernel.h>
21 #include <linux/io.h>
22 #include <linux/module.h>
23 #include <linux/spinlock.h>
24 #include <linux/genalloc.h>
25 #include <mach/iram.h>
26
27 static unsigned long iram_phys_base;
28 static void __iomem *iram_virt_base;
29 static struct gen_pool *iram_pool;
30
31 static inline void __iomem *iram_phys_to_virt(unsigned long p)
32 {
33 return iram_virt_base + (p - iram_phys_base);
34 }
35
36 void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37 {
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46 }
47 EXPORT_SYMBOL(iram_alloc);
48
49 void iram_free(unsigned long addr, unsigned int size)
50 {
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55 }
56 EXPORT_SYMBOL(iram_free);
57
58 int __init iram_init(unsigned long base, unsigned long size)
59 {
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73 }
ungaining/light
https://github.com/xbmc/xbmc/tree/master/lib/liblame/libmp3lame/quantize.h
1 /*
2 * MP3 quantization
3 *
4 * Copyright (c) 1999 Mark Taylor
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22 #ifndef LAME_QUANTIZE_H
23 #define LAME_QUANTIZE_H
24
25 void trancate_smallspectrums(lame_internal_flags const * gfc, gr_info * const gi,
26 const FLOAT * const l3_xmin, FLOAT * const work);
27
28 void CBR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
29 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
30
31 void VBR_old_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
32 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
33
34 void VBR_new_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
35 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
36
37 void ABR_iteration_loop(lame_global_flags const *gfp, FLOAT pe[2][2],
38 FLOAT ms_ratio[2], III_psy_ratio ratio[2][2]);
39
40
41 #endif /* LAME_QUANTIZE_H */
ungaining/light
https://github.com/marijnh/Postmodern/tree/master/postmodern/prepare.lisp
1 (in-package :postmodern)
2
3 (defun ensure-prepared (connection id query)
4 "Make sure a statement has been prepared for this connection."
5 (let ((meta (connection-meta connection)))
6 (unless (gethash id meta)
7 (setf (gethash id meta) t)
8 (prepare-query connection (symbol-name id) query))))
9
10 (let ((next-id 0))
11 (defun next-statement-id ()
12 "Provide unique statement names."
13 (incf next-id)
14 (intern (format nil "STATEMENT-~A" next-id) :keyword)))
15
16 (defun generate-prepared (function-form query format)
17 "Helper macro for the following two functions."
18 (destructuring-bind (reader result-form) (reader-for-format format)
19 (let ((base `(exec-prepared *database* (symbol-name statement-id) params ,reader)))
20 `(let ((statement-id (next-statement-id))
21 (query ,(real-query query)))
22 (,@function-form (&rest params)
23 (ensure-prepared *database* statement-id query)
24 (,result-form ,base))))))
25
26 (defmacro prepare (query &optional (format :rows))
27 "Wraps a query into a function that will prepare it once for a
28 connection, and then execute it with the given parameters. The query
29 should contain a placeholder \($1, $2, etc) for every parameter."
30 (generate-prepared '(lambda) query format))
31
32 (defmacro defprepared (name query &optional (format :rows))
33 "Like perpare, but gives the function a name instead of returning
34 it."
35 (generate-prepared `(defun ,name) query format))
36
37 (defmacro defprepared-with-names (name (&rest args)
38 (query &rest query-args)
39 &optional (format :rows))
40 "Like defprepared, but with lambda list for statement arguments."
41 (let ((prepared-name (gensym "STATEMENT")))
42 `(progn
43 (defprepared ,prepared-name ,query ,format)
44 (defun ,name ,args
45 (,prepared-name ,@query-args)))))
ungaining/light
https://github.com/erlang/otp/tree/master/lib/dialyzer/test/small_SUITE_data/src/no_return_bug.erl
1 %% Dialyzer couldn't infer that monitor_diskspace would go in an infinite loop
2 %% instead of crashing due to the existence of list comprehensions that have a
3 %% normal success typing. These were added to the monitor_diskspace's SCC and
4 %% dialyzer_typesig didn't try to assign unit() to monitor_diskspace, as it
5 %% required all the members of the SCC to return none().
6 %%
7 %% Testcase was submitted in erlang-questions mailing list by Prashanth Mundkur
8 %% (http://erlang.org/pipermail/erlang-questions/2011-May/058063.html)
9
10 -module(
no_return_bug).
11 -export(
[diskspace/1,
monitor_diskspace/2,
refresh_tags/1,
monitor_launch/0]).
12
13 -type diskinfo() ::
{non_neg_integer(),
non_neg_integer()
}.
14
15 -spec diskspace(
nonempty_string())
-> {'ok',
diskinfo()
} | {'error',
term()
}.
16 diskspace(
Path)
->
17 case Path of
18 "a" -> {ok,
{0,
0}};
19 _ -> {error,
error}
20 end.
21
22 -spec monitor_diskspace(
nonempty_string(),
23 [{diskinfo(),
nonempty_string()
}])
->
24 no_return().
25 monitor_diskspace(
Root,
Vols)
->
26 Df = fun(
VolName)
->
27 diskspace(
filename:join(
[Root,
VolName]))
28 end,
29 NewVols = [{Space,
VolName}
30 || {VolName,
{ok,
Space}}
31 <- [{VolName,
Df(
VolName)
}
32 || {_OldSpace,
VolName} <- Vols]],
33 monitor_diskspace(
Root,
NewVols).
34
35 -spec refresh_tags(
nonempty_string())
-> no_return().
36 refresh_tags(
Root)
->
37 {ok,
_} = diskspace(
Root),
38 refresh_tags(
Root).
39
40 monitor_launch()
->
41 spawn_link(
fun()
-> refresh_tags(
"abc")
end),
42 spawn_link(
fun()
-> monitor_diskspace(
"root",
[{{0,
0},
"a"}])
end).
ungaining/light
https://github.com/erlang/otp/tree/master/lib/ssh/src/ssh_userauth.hrl
1 %%
2 %% %CopyrightBegin%
3 %%
4 %% Copyright Ericsson AB 2005-2010. All Rights Reserved.
5 %%
6 %% The contents of this file are subject to the Erlang Public License,
7 %% Version 1.1, (the "License"); you may not use this file except in
8 %% compliance with the License. You should have received a copy of the
9 %% Erlang Public License along with this software. If not, it can be
10 %% retrieved online at http://www.erlang.org/.
11 %%
12 %% Software distributed under the License is distributed on an "AS IS"
13 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 %% the License for the specific language governing rights and limitations
15 %% under the License.
16 %%
17 %% %CopyrightEnd%
18 %%
19
20 %%
21
22 %%% Description: user authentication protocol
23
24 -define(
SSH_MSG_USERAUTH_REQUEST,
50).
25 -define(
SSH_MSG_USERAUTH_FAILURE,
51).
26 -define(
SSH_MSG_USERAUTH_SUCCESS,
52).
27 -define(
SSH_MSG_USERAUTH_BANNER,
53).
28 -define(
SSH_MSG_USERAUTH_PK_OK,
60).
29 -define(
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ,
60).
30 -define(
SSH_MSG_USERAUTH_INFO_REQUEST,
60).
31 -define(
SSH_MSG_USERAUTH_INFO_RESPONSE,
61).
32
33 -record(
ssh_msg_userauth_request,
34 {
35 user,
%% string
36 service,
%% string
37 method,
%% string "publickey", "password"
38 data %% opaque
39 }).
40
41 -record(
ssh_msg_userauth_failure,
42 {
43 authentications,
%% string
44 partial_success %% boolean
45 }).
46
47 -record(
ssh_msg_userauth_success,
48 {
49 }).
50
51 -record(
ssh_msg_userauth_banner,
52 {
53 message,
%% string
54 language %% string
55 }).
56
57 -record(
ssh_msg_userauth_passwd_changereq,
58 {
59 prompt,
%% string
60 languge %% string
61 }).
62
63 -record(
ssh_msg_userauth_pk_ok,
64 {
65 algorithm_name,
% string
66 key_blob % string
67 }).
68
69 -record(
ssh_msg_userauth_info_request,
70 {name,
71 instruction,
72 language_tag,
73 num_prompts,
74 data}).
75 -record(
ssh_msg_userauth_info_response,
76 {num_responses,
77 data}).
ungaining/light
https://github.com/Bukkit/Bukkit/tree/master/src/main/java/org/bukkit/fillr/Getter.java
1 package org.bukkit.fillr;
2
3 import java.io.File;
4 import java.util.logging.Level;
5
6 import org.bukkit.*;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.plugin.InvalidDescriptionException;
9 import org.bukkit.plugin.InvalidPluginException;
10 import org.bukkit.plugin.UnknownDependencyException;
11
12 public class Getter {
13 private Server server;
14 private static String DIRECTORY = Fillr.DIRECTORY;
15
16 public Getter(Server server) {
17 this.server = server;
18 }
19
20 public void get(String string, CommandSender sender) {
21 FillReader reader = new FillReader(string);
22
23 sender.sendMessage("Downloading " + reader.getName() + " " + reader.getCurrVersion());
24 try {
25 Downloader.downloadJar(reader.getFile());
26 if (reader.getNotes() != null && !reader.getNotes().equals("")) {
27 sender.sendMessage("Notes: " + reader.getNotes());
28 }
29 sender.sendMessage("Finished Download!");
30 enablePlugin(reader);
31 sender.sendMessage("Loading " + reader.getName());
32 } catch (Exception ex) {
33 server.getLogger().log(Level.SEVERE, null, ex);
34 }
35 }
36
37 private void enablePlugin(FillReader update) {
38 final String name = update.getName();
39 // TODO again with the implicit jar support...
40
41 File plugin = new File(DIRECTORY, name + ".jar");
42
43 try {
44 server.getPluginManager().loadPlugin(plugin);
45 } catch (UnknownDependencyException ex) {
46 server.getLogger().log(Level.SEVERE, null, ex);
47 } catch (InvalidPluginException ex) {
48 server.getLogger().log(Level.SEVERE, null, ex);
49 } catch (InvalidDescriptionException ex) {
50 server.getLogger().log(Level.SEVERE, null, ex);
51 }
52 }
53 }
ungaining/light
https://github.com/joyent/node/tree/master/deps/v8/test/mjsunit/number-string-index-call.js
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 var callbacks = [ function() {return 'foo'}, "nonobject", /abc/ ];
29 assertEquals('foo', callbacks['0']());
30 assertThrows("callbacks['1']()");
31 assertThrows("callbacks['2']('abcdefg')");
ungaining/light
https://github.com/facebook/three20/tree/master/src/Three20UI/Sources/TTTableItem.m
1 //
2 // Copyright 2009-2011 Facebook
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #import "Three20UI/TTTableItem.h"
18
19 // Core
20 #import "Three20Core/TTCorePreprocessorMacros.h"
21
22
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////////////////////////
26 @implementation TTTableItem
27
28 @synthesize userInfo = _userInfo;
29
30
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
32 - (
void)dealloc {
33 TT_RELEASE_SAFELY(_userInfo);
34
35 [
super dealloc];
36 }
37
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 #pragma mark -
42 #pragma mark NSCoding
43
44
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46 - (
id)initWithCoder:(NSCoder*)decoder {
47 self = [
self init];
48 if (
self) {
49 }
50
51 return self;
52 }
53
54
55 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 - (
void)encodeWithCoder:(NSCoder*)encoder {
57 }
58
59
60 @end
ungaining/light
https://github.com/facebook/three20/tree/master/src/extThree20JSON/Vendors/YAJL/yajl/src/yajl_alloc.h
1 /*
2 * Copyright 2010, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /**
34 * \file yajl_alloc.h
35 * default memory allocation routines for yajl which use malloc/realloc and
36 * free
37 */
38
39 #ifndef __YAJL_ALLOC_H__
40 #define __YAJL_ALLOC_H__
41
42 #include "extThree20JSON/yajl_common.h"
43
44 #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
45 #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
46 #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
47
48 void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
49
50 #endif
ungaining/light
https://github.com/mirrors/perl/tree/master/os2/OS2/OS2-Process/Makefile.PL
1 use ExtUtils::MakeMaker;
2
3 create_constants(); # Make a module
4
5 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6 # the contents of the Makefile that is written.
7 WriteMakefile(
8 'NAME' => 'OS2::Process',
9 VERSION_FROM=> 'Process.pm',
10 MAN3PODS => {}, # Pods will be built by installman.
11 'LIBS' => [''], # e.g., '-lm'
12 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
13 'INC' => '', # e.g., '-I/usr/include/other'
14 IMPORTS => { _16_DosSmSetTitle => 'sesmgr.DOSSMSETTITLE',
15 # _16_Win16SetTitle => 'pmshapi.93',
16 },
17 );
18
19 sub create_constants {
20 return if -d 'Process_constants';
21 my $src_dir;
22 my @try = qw(.. ../.. ../../.. ../../../..);
23 for (@try) {
24 $src_dir = $_, last if -d "$_/utils" and -r "$_/utils/h2xs";
25 }
26 warn("Can't find \$PERL_SRC/utils/h2xs in @try, falling back to no constants"),
27 return unless defined $src_dir;
28 # Can't name it *::Constants, otherwise constants.xs would overwrite it...
29 # This produces warnings from PSZ-conversion on WS_* constants.
30 system $^X, "-I$src_dir/lib", "$src_dir/utils/h2xs", '-fn', 'OS2::Process::Const',
31 '--skip-exporter', '--skip-autoloader', # too large memory overhead
32 '--skip-strict', '--skip-warnings', # likewise
33 '--skip-ppport', # will not work without dynaloading.
34 # Most useful for OS2::Process:
35 '-M^(HWND|WM|SC|SWP|WC|PROG|QW|EDI|WS|QWS|QWP|QWL|FF|FI|LS|FS|FCF|BS|MS|TBM|CF|CFI|FID|MB|MBID|CF|CFI|SPTR)_',
36 '-F', '-DINCL_NLS -DINCL_BASE -DINCL_PM', # Define more symbols
37 'os2emx.h' # EMX version of OS/2 API
38 and warn("Can't build module with contants, falling back to no constants"),
39 return;
40 rename 'OS2/Process/Const', 'Process_constants'
41 or warn("Error renaming module, falling back to no constants: $!"),
42 return;
43 return 1;
44 }
ungaining/light
https://github.com/emesene/emesene/tree/master/emesene/e3/papylib/papyon/papyon/service/description/RSI/GetMessage.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2007 Johann Prieur <johann.prieur@gmail.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19
20 from common
import *
21
22 def transport_headers():
23 """Returns a dictionary, containing transport (http) headers
24 to use for the request"""
25
26 return {}
27
28 def soap_action():
29 """Returns the SOAPAction value to pass to the transport
30 or None if no SOAPAction needs to be specified"""
31
32 return "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage"
33
34 def soap_body(message_id, also_mark_as_read):
35 """Returns the SOAP xml body
36
37 @param message_id: the id of the message to get (guid)
38 @param also_mark_as_read: "true if the message should be marked as read
39 "false else
40 """
41 return """
42 <GetMessage xmlns="http://www.hotmail.msn.com/ws/2004/09/oim/rsi">
43 <messageId>%s</messageId>
44 <alsoMarkAsRead>%s</alsoMarkAsRead>
45 </GetMessage>""" % (message_id, also_mark_as_read)
46
47 def process_response(soap_response):
48 return soap_response.body.
\
49 find(
"./rsi:GetMessageResponse/rsi:GetMessageResult")
ungaining/light
https://github.com/diaspora/diaspora/tree/master/app/helpers/aspects_helper.rb
1 # Copyright (c) 2010-2011, Diaspora Inc. This file is
2 # licensed under the Affero General Public License version 3 or later. See
3 # the COPYRIGHT file.
4
5 module AspectsHelper
6 def remove_link(aspect)
7 if aspect.contacts.size == 0
8 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
9 else
10 "<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
11 end
12 end
13
14 def add_to_aspect_button(aspect_id, person_id)
15 link_to image_tag('icons/monotone_plus_add_round.png'),
16 {:controller => 'aspect_memberships',
17 :action => 'create',
18 :aspect_id => aspect_id,
19 :person_id => person_id},
20 :remote => true,
21 :method => 'post',
22 :class => 'add button',
23 'data-aspect_id' => aspect_id,
24 'data-person_id' => person_id
25 end
26
27 def remove_from_aspect_button(aspect_id, person_id)
28 link_to image_tag('icons/monotone_check_yes.png'),
29 {:controller => "aspect_memberships",
30 :action => 'destroy',
31 :id => 42,
32 :aspect_id => aspect_id,
33 :person_id => person_id},
34 :remote => true,
35 :method => 'delete',
36 :class => 'added button',
37 'data-aspect_id' => aspect_id,
38 'data-person_id' => person_id
39 end
40
41 def aspect_membership_button(aspect, contact, person)
42 if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
43 add_to_aspect_button(aspect.id, person.id)
44 else
45 remove_from_aspect_button(aspect.id, person.id)
46 end
47 end
48 end
ungaining/light
https://github.com/jimweirich/sicp-study/tree/master/scheme/chapter1/ex1_28.scm
1 ;; SICP 1.28
2
3 ;; Exercise 1.28. One variant of the Fermat test that cannot be
4 ;; fooled is called the Miller-Rabin test (Miller 1976; Rabin
5 ;; 1980). This starts from an alternate form of Fermat's Little
6 ;; Theorem, which states that if n is a prime number and a is any
7 ;; positive integer less than n, then a raised to the (n - 1)st power
8 ;; is congruent to 1 modulo n. To test the primality of a number n by
9 ;; the Miller-Rabin test, we pick a random number a<n and raise a to
10 ;; the (n - 1)st power modulo n using the expmod procedure. However,
11 ;; whenever we perform the squaring step in expmod, we check to see if
12 ;; we have discovered a ``nontrivial square root of 1 modulo n,'' that
13 ;; is, a number not equal to 1 or n - 1 whose square is equal to 1
14 ;; modulo n. It is possible to prove that if such a nontrivial square
15 ;; root of 1 exists, then n is not prime. It is also possible to prove
16 ;; that if n is an odd number that is not prime, then, for at least
17 ;; half the numbers a<n, computing a^(n-1) in this way will reveal a
18 ;; nontrivial square root of 1 modulo n. (This is why the Miller-Rabin
19 ;; test cannot be fooled.) Modify the expmod procedure to signal if it
20 ;; discovers a nontrivial square root of 1, and use this to implement
21 ;; the Miller-Rabin test with a procedure analogous to
22 ;; fermat-test. Check your procedure by testing various known primes
23 ;; and non-primes. Hint: One convenient way to make expmod signal is
24 ;; to have it return 0.
25
26 ;; ANSWER ------------------------------------------------------------
27
28 ;; Ok, I've never finished this one. It is a wee bit too math-deep
29 ;; for even me.
ungaining/light
https://github.com/dyoo/moby-scheme/tree/master/sandbox/old-src/stub/world-config.ss
1 #lang scheme/base
2
3 (define-struct world-config () #:prefab)
4
5 (define-struct (world-config:on-key world-config) (f ef) #:prefab)
6 (define-struct (world-config:on-tick world-config) (delay f ef) #:prefab)
7 (define-struct (world-config:initial-effect world-config) (e) #:prefab)
8 (define-struct (world-config:on-location-change world-config) (f ef) #:prefab)
9 (define-struct (world-config:on-tilt world-config) (f ef) #:prefab)
10 (define-struct (world-config:on-acceleration world-config) (f ef) #:prefab)
11 (define-struct (world-config:on-shake world-config) (f ef) #:prefab)
12 (define-struct (world-config:on-redraw world-config) (f) #:prefab)
13 (define-struct (world-config:on-draw world-config) (f css-f) #:prefab)
14 (define-struct (world-config:stop-when world-config) (f) #:prefab)
15
16 (define (initial-effect e)
17 (make-world-config:initial-effect e))
18
19 (define (on-key f)
20 (make-world-config:on-key f (lambda (w k) '())))
21
22 (define (on-key! f ef)
23 (make-world-config:on-key f ef))
24
25 (define (on-tick delay f)
26 (make-world-config:on-tick delay f (lambda (w) '())))
27
28 (define (on-tick! delay f ef)
29 (make-world-config:on-tick delay f ef))
30
31 (define (on-location-change f)
32 (make-world-config:on-location-change f (lambda (w lat long) '())))
33
34 (define (on-location-change! f ef)
35 (make-world-config:on-location-change f ef))
36
37 (define (on-tilt f)
38 (make-world-config:on-tilt f (lambda (w azimuth pitch roll) '())))
39
40 (define (on-tilt! f ef)
41 (make-world-config:on-tilt f ef))
42
43 (define (on-acceleration f)
44 (make-world-config:on-acceleration f (lambda (w x y z) '())))
45
46 (define (on-acceleration! f ef)
47 (make-world-config:on-acceleration f ef))
48
49 (define (on-shake f)
50 (make-world-config:on-shake f (lambda (w) '())))
51
52 (define (on-shake! f ef)
53 (make-world-config:on-shake f ef))
54
55 (define (on-redraw f)
56 (make-world-config:on-redraw f))
57
58 (define (on-draw f css-f)
59 (make-world-config:on-draw f css-f))
60
61 (define (stop-when f)
62 (make-world-config:stop-when f))
63
64
65 (provide (all-defined-out))